home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / inline.arc / INLINE.DOC < prev   
Encoding:
Text File  |  1985-11-22  |  8.4 KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                              November 15, 1985
  9.  
  10.                         INLINE ASSEMBLER
  11.  
  12.  
  13. OVERVIEW
  14.  
  15. INLINE.COM is an assembler designed to produce Inline 8086/8088 
  16. code for Turbo Pascal (tm) version 3 programs.  Like other 
  17. assemblers, INLINE accepts as input an assembly language source 
  18. file and produces an object file.  However, in this case, the 
  19. 'object' file is an ASCII file consisting of Inline statements 
  20. which may be inserted into the Turbo Pascal program.
  21.  
  22. Figure 1 illustrates a Pascal function with Inline code generated 
  23. by INLINE using the source file of Figure 2.
  24.  
  25.  
  26. LOADING AND RUNNING INLINE
  27.  
  28. INLINE is called at the DOS prompt with two filename parameters 
  29. specifying the names of the source and object files.  If no 
  30. extensions are given, .ASM and .OBJ are used by default.  For 
  31. instance,
  32.  
  33.   INLINE ABC DEF
  34.  
  35. will cause INLINE to look for a source file, ABC.ASM, and create 
  36. an object file, DEF.OBJ.  Files with no extension may be input or 
  37. created by using a simple '.' for the extension.
  38.  
  39. If one or more filenames are missing from the command line, they 
  40. will be requested once execution starts.
  41.  
  42. Once execution begins, INLINE will run to completion with the 
  43. only console output being error messages.
  44.  
  45.  
  46. SYNTAX
  47.  
  48. The appendix lists the mnemonics accepted by INLINE.  Syntax and 
  49. mnemonics correspond to that used by most assemblers but note 
  50. should be made of the following:
  51.  
  52.   1. Turbo Pascal symbols may be used within instruction entries 
  53.      by preceding the symbol with a '>' (16 bit symbol) or a '<' 
  54.      (8 bit symbol).  The characters '+' and '-' are considered 
  55.      part of the symbol.  This allows computations using symbols 
  56.      to be passed on to the compiler where the computation can be 
  57.      made.  For instance in
  58.  
  59.  
  60.  
  61.  
  62.                            1
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.          MOV AX,[>SYMBOL+4]       ;'>SYMBOL+4' is passed on
  75.          MOV AX,[BP+>SYMBOL+4]    ;again '>SYMBOL+4' is passed on
  76.          MOV AX,>SYMBOL+4[BP]     ;also acceptable
  77.  
  78.      Note that
  79.  
  80.          MOV AX,[>SYMBOL+4+BP]
  81.  
  82.      is not correct since the wrong instruction will be generated 
  83.      and '>SYMBOL+4+BP' will be passed on.
  84.  
  85.   2. Labels (for use with jump instructions) may be defined 
  86.      simply by appending a ':' to the first item on a line.
  87.  
  88.   3. Numerical entries are assumed to be decimal unless preceded 
  89.      by a '$' indicating a hexadecimal entry.  Characters within 
  90.      single quotes may be used for numerical entries as:
  91.  
  92.          CMP AL,'a'
  93.  
  94.   4. Square brackets are used to indicate 'contents of'.  If no 
  95.      square brackets are used, an immediate operand is assumed.
  96.  
  97.          MOV AX,[>DATA]  ;Load AX with the contents of DATA.
  98.          MOV AX,>DATA    ;Load AX with DATA.
  99.  
  100.   5. Instruction prefixes and segment override prefixes may 
  101.      precede the instruction on the same line or may be included 
  102.      on a previous line.
  103.  
  104.   6. Comments may be include in the source.  They are delimited 
  105.      by a ';'.
  106.  
  107.   7. Instructions which don't clearly specify the data size 
  108.      require that BYTE PTR or WORD PTR be used.  These may be 
  109.      abbreviated to BY or WO.
  110.  
  111.          INC BYTE PTR [>BDATA]
  112.          DEC WO >WARRAY[DI]
  113.  
  114.   8. JMP instructions may use SHORT, NEAR, or FAR (they should 
  115.      not be abbreviated).  In the absence of one of these words, a 
  116.      SHORT jump will be encoded if the label is already defined 
  117.      and is within range.  If the label is not defined, a NEAR 
  118.      JMP will be encoded unless SHORT is used.
  119.  
  120.      A FAR CALL or JMP may be made to a direct address by stating 
  121.      both the segment and offset separated by a colon.
  122.  
  123.          CALL FAR $1234:$5678
  124.  
  125.  
  126.  
  127.  
  128.                            2
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. RESTRICTIONS
  141.  
  142. The object file is limited to 32k.  This includes comments and 
  143. spaces.
  144.  
  145. Symbols (including any addons from + and -) are limited to 32 
  146. characters.
  147.  
  148. Labels may be used in jump statements only and not as data 
  149. references.  While there is a DB pseudo-opcode, it is not very 
  150. useful with this restriction.
  151.  
  152. The number of statement labels that may be defined is limited 
  153. only by the heap space available.
  154.  
  155.  
  156. Please report all bugs, suggestions, and problems to Dave 
  157. Baldwin, CompuServe ID #76327,53.
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.                            3
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207. FUNCTION SCAN(LIMIT :INTEGER; CH :CHAR; VAR T ): INTEGER;
  208. {SCAN LIMIT CHARACTERS FOR CH. RETURN THE NUMBER OF CHARACTERS
  209.  SKIPPED TO FIND A MATCH.  IF NOT FOUND, RETURN RESULT=LIMIT.
  210.  LIMIT MAY BE NEGATIVE FOR A BACKWARDS SCAN.}
  211. BEGIN    {SCAN MUST BE FAST--USE ASSEMBLY LANGUAGE}
  212. Inline(
  213.   $FC             {    CLD              ;ASSUME FORWARD}                      
  214.   /$8A/$46/<CH    {    MOV AL,<CH[BP]   ;CHAR TO SEARCH FOR}                  
  215.   /$8B/$4E/<LIMIT {    MOV CX,<LIMIT[BP];BYTES TO SEARCH}                     
  216.   /$09/$C9        {    OR CX,CX         ;CHECK SIGN}                          
  217.   /$9C            {    PUSHF            ;SAVE FLAGS}                          
  218.   /$79/$03        {     JNS X1}                                               
  219.   /$F7/$D9        {    NEG CX           ;MAKE POSITIVE}                       
  220.   /$FD            {    STD              ;BUT SEARCH IN REVERSE}               
  221.   /$89/$CA        {X1: MOV DX,CX        ;SAVE FULL COUNT}                     
  222.   /$C4/$7E/<T     {    LES DI,<T[BP]    ;PTR TO START}                        
  223.   /$F2/$AE        {    REPNE: SCASB     ;SEARCH}                              
  224.   /$75/$01        {     JNE X2}                                               
  225.   /$41            {    INC CX           ;FOUND A MATCH}                       
  226.   /$29/$CA        {X2: SUB DX,CX        ;FIND COUNT TO MATCH}                 
  227.   /$9D            {    POPF}                                                  
  228.   /$79/$02        {     JNS X3}                                               
  229.   /$F7/$DA        {    NEG DX           ;MAKE NEGATIVE IF REVERSE}            
  230.   /$89/$56/$0C    {X3: MOV [BP+$C],DX   ;PUT IN FUNCTION RESULT}              
  231. );
  232. END;
  233.  
  234.            Figure 1: Pascal Function using Inline Code
  235.  
  236.  
  237.     CLD              ;ASSUME FORWARD
  238.     MOV AL,<CH[BP]   ;CHAR TO SEARCH FOR
  239.     MOV CX,<LIMIT[BP];BYTES TO SEARCH
  240.     OR CX,CX         ;CHECK SIGN
  241.     PUSHF            ;SAVE FLAGS
  242.      JNS X1
  243.     NEG CX           ;MAKE POSITIVE
  244.     STD              ;BUT SEARCH IN REVERSE
  245. X1: MOV DX,CX        ;SAVE FULL COUNT
  246.     LES DI,<T[BP]    ;PTR TO START
  247.     REPNE: SCASB     ;SEARCH
  248.      JNE X2
  249.     INC CX           ;FOUND A MATCH
  250. X2: SUB DX,CX        ;FIND COUNT TO MATCH
  251.     POPF
  252.      JNS X3
  253.     NEG DX           ;MAKE NEGATIVE IF REVERSE
  254. X3: MOV [BP+$C],DX   ;PUT IN FUNCTION RESULT
  255.  
  256.                   Figure 2:  INLINE Input File
  257.  
  258.  
  259.  
  260.                            4
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274. APPENDIX
  275.  
  276.   8086/8088 Opcode Mnemonics Recognized by INLINE
  277.  
  278.         AAA       HLT       JNE       LOOPNZ    ROR    
  279.         AAD       IDIV      JNG       LOOPZ     SAHF   
  280.         AAM       IMUL      JNGE      MOV       SAL    
  281.         AAS       IN        JNL       MOVSB     SAR    
  282.         ADC       INC       JNLE      MOVSW     SBB    
  283.         ADD       INT       JNO       MUL       SCASB  
  284.         AND       INTO      JNP       NEG       SCASW  
  285.         CALL      IRET      JNS       NOP       SHL    
  286.         CBW       JA        JNZ       NOT       SHR    
  287.         CLC       JAE       JO        OR        SS     
  288.         CLD       JB        JP        OUT       STC    
  289.         CLI       JBE       JPE       POP       STD    
  290.         CMC       JC        JPO       POPF      STI    
  291.         CMP       JCXZ      JS        PUSH      STOSB  
  292.         CMPSB     JE        JZ        PUSHF     STOSW  
  293.         CMPSW     JG        LAHF      RCL       SUB    
  294.         CS        JGE       LDS       RCR       TEST   
  295.         CWD       JL        LEA       REP       WAIT   
  296.         DAA       JLE       LES       REPE      XCHG   
  297.         DAS       JMP       LOCK      REPNE     XLAT   
  298.         DB        JNA       LODSB     REPNZ     XOR    
  299.         DEC       JNAE      LODSW     REPZ   
  300.         DIV       JNB       LOOP      RET    
  301.         DS        JNBE      LOOPE     RETF   
  302.         ES        JNC       LOOPNE    ROL    
  303.  
  304.  
  305.  
  306.  
  307.  
  308.      Turbo Pascal is a trademark of Borland International Inc.
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.                            5
  327.  
  328.  
  329.  
  330.  
  331.